package org.checkboo.hopefullyengine.scenegraph;

import java.util.LinkedList;

import org.checkboo.hopefullyengine.boundingvolumes.AxisAlignedBoundingBox;
import org.checkboo.hopefullyengine.boundingvolumes.BoundingVolume;

public class GroupNode extends Node {

	private LinkedList<Node> children;
	private BoundingVolume boundingVolume;
	
	public GroupNode(String name){
		super(name);
		this.children = new LinkedList<Node>();
	}

	public void addChild(Node child){
		this.children.add(child);
	}
	
	public LinkedList<Node> getChildren() {
		return children;
	}

	public void setChildren(LinkedList<Node> children) {
		this.children = children;
	}

	public BoundingVolume getBoundingVolume() {
		return boundingVolume;
	}

	public void setBoundingVolume(BoundingVolume boundingVolume) {
		this.boundingVolume = boundingVolume;
	}
	
	public BoundingVolume updateBound(){
		if(null == this.boundingVolume)
			this.boundingVolume = new AxisAlignedBoundingBox();
		if(!this.boundingVolume.updateBound(this))
			this.boundingVolume = null;
		return this.boundingVolume;
	}
}
